import json

import pandas as pd

# 读取Excel文件
file_path = 'D:\\工作文档\\多诊合参逻辑\\头面红外合参\\红外头面反推证候逻辑.xlsx'
df = pd.read_excel(file_path, header=0, engine='openpyxl')
df['necessary_condition'] = df['necessary_condition'].str.replace('\n', '').str.strip()
df['minor_condition'] = df['minor_condition'].str.replace('\n', '').str.strip()
# 显示前5行数据
json_data = df.to_json(orient='records')
array = json.loads(json_data)
for item in array:
    # 插入数据的SQL语句
    sql = "INSERT INTO reverse_syndrome_dict (code, name, necessary_condition, minor_condition, status, type) VALUES ('{}', '{}', `{}`, `{}`,{}, {});".format(
        item["code"], item['name'], json.loads(item['necessary_condition']),
        json.loads(item['minor_condition']), item['status'], item['type'])
    print(sql.replace("'", '"'))
